<?php
/**
 * Created by PhpStorm.
 * User: BlueIdeaLirui
 * Date: 2019/11/8
 * Time: 18:29
 */

namespace search\controllers\bigdata;

use business\elasticsearch\services\MaterialService;

class MaterialController extends BaseController
{
    public function actionIndex()
    {
        try {
            $keyword              = $this->getParam('keyword');
            $onlyAreaCode         = $this->getParam('onlyAreaCode');
            $materialCategoryCode = $this->getParam('materialCategoryCode');

            $page                 = (int)$this->getParam('page', 'get', '1');
            $pageSize             = (int)$this->getParam('pagesize', 'get', '10');
            return $this->success((new MaterialService())->getList(
                $keyword, $onlyAreaCode, $materialCategoryCode, $page, $pageSize));
        } catch (\Exception $ex){
            \Yii::error($ex->getMessage());
            return $this->error('', '获取失败，请稍后重试');
        }
    }
}
